<template>
	<view>
		<custom :title="feedback_index == 'app'?'反馈与建议':'投诉'" fixed="fixed" border="0.5px solid rgba(0,0,0,0.1)">

			<!-- <view slot="right" class="fs-28 color" style="transform: translateX(-12rpx);" @tap.stop="submit">
				提交
			</view> -->
		</custom>

		<view class="flex">
			<view class="flex-content">
				<!-- <view class="mt-30">
					<text style="color: #FC543B;">*</text>
					<text class="fs-30 color-333333">反馈类型</text>
				</view> -->

				<!-- <view class="flex flex-wrap">
					<view @tap.stop="change_type(index)" class="mt-20 type-item flex flex-x-y"
						:style="index == feedback_index ?'background-color:#6D9EFB;':''"
						v-for="(item,index) in feedback_type" :key="index">{{item}}</view>
				</view>
 -->
				<!-- <view class="mt-30">
					<text style="color: #FC543B;">*</text>
					<text class="fs-30 color-333333">反馈类型</text>
				</view> -->

				<view class="bg-FFFFFF mt-20 br-20">
					<view class="pr">
						<textarea :placeholder="feedback_index == 'app'?'请填写你的宝贵意见和建议～':'请填写你要投诉的原因'" v-model="remark"
							:maxlength="200" class="remark-box"></textarea>

						<view class="remark-num">
							{{get_num()}}/200
						</view>
					</view>
				</view>



                <!-- vivo审核 -->
				<view class="mt-20 bg-FFFFFF br-20" style="padding: 6rpx 0 20rpx 20rpx;">
					<upload desc="图片" @change="chang_image" ref="upload" marginRight="16rpx" marginTop="14rpx"
						:length="8" width="150rpx" height="150rpx"></upload>
				</view>

				<!-- 	<view class="mt-30 flex flex-y-center"
					style="margin-top: 72rpx;padding-bottom: 30rpx;border-bottom: 2rpx solid #eeeeee;">
					<text style="color: #FC543B;">*</text>
					<text class="fs-30 color-333333">您的姓名</text>
					<input type="text" placeholder="请输入您的姓名" placeholder-class="font" class="fs-32 color-333333 flex-1"
						style="margin-left: 43rpx;" v-model="name" maxlength="10">
				</view> -->
				<!-- <view class="mt-30 flex flex-y-center" style="margin-top: 32rpx;padding-bottom: 30rpx;">
					<text class="fs-30 color-333333">联系方式</text>

				</view>
				<input type="number" placeholder="请填写你的手机号" placeholder-class="font" class="fs-26 color-black flex-1"
					style="margin-left: 0rpx;background-color: #F2F2F3;height: 72rpx;border-radius: 16rpx;padding-left: 20rpx;"
					:maxlength="11" v-model="mobile"> -->

				<!-- <view class="flex flex-x-y">
					<view class="br-16 bg-all flex flex-x-y color-ffffff fs-28"
						style="height: 80rpx;margin-top: 88rpx;width: 670rpx;" @tap.stop="submit">提交</view>
				</view> -->
				<view style="height: 50rpx;"></view>


			</view>


		</view>

		<fixed-bottom>
			<view class="flex flex-x-y" style="padding-bottom: 50rpx;">
				<view class="default-btn" @tap.stop="submit" style="width: 550rpx;">
					提交
				</view>
			</view>
		</fixed-bottom>
		<toast ref="toast"></toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				feedback_type: {
					'friend': '单聊投诉',
					'group': '群聊投诉',
					'app': '反馈建议'
				},
				feedback_index: 'app',
				remark: '',
				mobile: '',
				img_list: [],
				name: '',
				reportedId: '',
			}
		},
		onLoad(e) {
			if (e.type) {
				this.feedback_index = e.type;
			}
			if (e.reportedId) {
				this.reportedId = e.reportedId;
			}
		},
		methods: {
			change_type(index) {
				this.feedback_index = index;
			},
			get_num() {
				let num = String(this.remark).trim().length;
				return num >= 200 ? 200 : num;
			},
			chang_image(list) {
				console.log('ssss', list);
				this.img_list = list.filter(val => val.id).map(val => val.src);
			},
			get_feedback_type(type) {
				switch (type) {
					case 'app':
						return 1;
					case 'group':
						return 3;
					case 'friend':
						return 2;
				}
			},
			submit() {

				this.click(() => {
					if (this.remark.trim().length == 0) {
						this.showToast('请输入反馈信息哦');
						return;
					}

					// if (!(/^1[3456789]\d{9}$/.test(this.mobile))) {
					// 	this.showToast("请输入正确的联系方式");
					// 	return;
					// }
					this.request({
						url: '/feedback/add',
						data: {
							// type: this.feedback_type[this.feedback_index] || this.feedback_index,
							detail: this.remark.trim(),
							image: this.img_list.join(','),
							name: this.user_info.name,
							phone: this.user_info.phone,
							reportedId: this.reportedId,
							type: this.get_feedback_type(this.feedback_index),

						},
						method: 'POST',
						loading: true,
					}).then(res => {
						if (!this.rsuccess(res)) return;
						this.$refs.toast.open({
							left: '',
							desc: '反馈成功',
							success: () => {
								this.uniBack();
							}
						});
					});
				});

			},
		}
	}
</script>

<style lang="scss">

	page {
		background-color: $pageColor;
	}

	.type-item {
		width: 180rpx;
		height: 60rpx;
		border-radius: 36rpx;
		background-color: rgba(109, 158, 251, 0.4);
		margin-right: 32rpx;
		font-size: 26rpx;
	}

	.remark-box {
		font-size: 28rpx;
		color: #333;
		width: 100%;
		min-height: 218rpx;

		border-radius: 8rpx;
		padding: 24rpx;
	}

	.remark-num {
		position: absolute;
		z-index: 3;
		right: 32rpx;
		bottom: 24rpx;
		font-size: 28rpx;
		color: #999;
	}
</style>